package com.itxckf.mapper;


import com.itxckf.pojo.Products;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CartMapper {
    @Insert("INSERT INTO ShoppingCart (UserID, ProductID) VALUES (#{userID}, #{productID});")
    void addCart(@Param("userID") Short userID,@Param("productID") Short productID);

    @Select("SELECT s.*, p.*, s1.ShopName FROM ShoppingCart s JOIN Products p ON s.ProductID = p.ProductID JOIN Shops s1 ON p.ShopID = s1.ShopID WHERE s.UserID = #{userID}")
        List<Products> getCart(Short userID);
}
